package com;

import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import javax.naming.NamingException;

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class LogoutExecutor {
    @Resource
    private NamedParameterJdbcTemplate namedParameterJdbcTemplate;

    @Transactional
    public void logout(String name) throws IOException, SQLException, NamingException {
        String query = "DELETE FROM users WHERE nickname =:nickname;";
        Map namedParameters = new HashMap();
        namedParameters.put("nickname", name);

        namedParameterJdbcTemplate.update(query, namedParameters);

    }

}
